	// Form 表单
	var Form=function(selector){
		this.selector=selector;
		this.element=$(selector).get(0);
	}
	Form.prototype=new Control();
	
	Form.prototype.ruleUrl="./formRule.json";
	Form.prototype.init=function(){
		//关闭验证 测试
		//return false;
		var self=this;
		$(this.selector).bind("submit",function(event){return self.submitHandler(event)})

		this.ruleParser=new RuleParser(this.selector);
		this.ruleParser.loadRule(this.ruleUrl);
	}
	Form.prototype.preSubmitHandler=function(){
		return true;
	}
	Form.prototype.validate=function(){
		return true;
	}
	Form.prototype.submitHandler=function(event){
		try{
			this.preSubmitHandler();
			if(!this.validate()){
				return false;
			}
		}catch(error){
			console.log(error);
		}
		var self=this;
		try{
			var success=this.ruleParser.validate();
			if(!success){
				//输出提示
				var result=this.ruleParser.validateResult;
				var tips=result.getResultListFailTips();
				alert(tips);
				
				//设置焦点
				var resultList=result.resultList
				for(var i=0;i<resultList.length;i++){
					if(resultList[i].event=="eventFail"){
						var name=resultList[i].target
						$("[name='"+name+"']",this.selector).focus();
						break;
					}
				}
				return false;
			}
			//alert("提交成功");
			//return false;
			return true;
		}catch(e){
			console.log(e);
			alert("提交失败");
			return false;
		}
		return true;
	}
	Form.prototype.getValueByName=function(name){
		var dataList=$(this.selector).serializeArray();
		var data;
		var valueArray=new Array();
		for(var i=0;i<dataList.length;i++){
			data=dataList[i]
			if(data.name==name){
				valueArray.push(data.value);
			}
		}
		return valueArray.join(",");
	}
	HTMLTurbo.control.Form=Form;